package com.zretc.file.dao;


import com.zretc.api.pojo.filesAndFriendModule.Files;
import com.zretc.api.pojo.filesAndFriendModule.dto.QueryFileListDTO;
import com.zretc.api.pojo.filesAndFriendModule.vo.FileListVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Page;

import java.util.ArrayList;


@Mapper
public interface FileControlMapper {
    @Insert("insert into resource (type, resource_name, url, size, statu, uploader_id, uploader_name, fileuuid, download_count, upload_time) "+
            "values " +
            "(#{type},#{name},#{url},#{size},#{statu},#{uploaderId},#{uploaderName},#{fileUUID},#{downloadCount},#{uploadTime})")
    void save(Files files);

    String searchUrlByFileUUID(String fileUUID);

    Integer searchCountByFileUUID(String fileUUID);


    void updateCount(Files updateCount);

    //Page<FileListVO> fileList(QueryFileListDTO queryFileListDTO);
    @Delete("delete from sns.resource where fileUUID = #{fileUUID}")
    void deleteFile(String fileUUID);

    ArrayList<FileListVO> queryByPage(@Param("startIndex") Integer startIndex,
                                      @Param("pageSize") Integer pageSize,@Param("type") String type,@Param("keyword") String keyword);

    Integer getCount();
}
